package com.retail.lottery.colalottery.controller;

import com.retail.lottery.colalottery.annotation.CheckHeader;
import com.retail.lottery.colalottery.annotation.EncryptResponse;
import com.retail.lottery.colalottery.service.WechatCustomerService;
import com.retail.lottery.colalottery.vo.ResultVO;
import com.retail.lottery.colalottery.vo.request.SaveUserInfoRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.HandlerMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.UUID;

@RestController
@RequestMapping("/user-login")
@Slf4j
public class UserLoginController {

    @Resource
    private WechatCustomerService wechatCustomerService;

    /**
     * 后端客户端登录（未使用）
     *
     * @param
     * @return
     */
//    @EncryptResponse
//    //@DecryptResponse
//    @GetMapping("/api/sp-portal/store/{buCode}/wechat/loginNoCache/{code}")
//    @CheckHeader(requiredHeaders = {"Authorization"})
//    public ResultVO<?> userLoginNoCache(HttpServletRequest request,
//                                        @PathVariable String buCode,
//                                        @PathVariable String code,
//                                        @RequestParam("source") String source,
//                                        @RequestParam("oneid") String oneid,
//                                        @RequestParam("encryptMobile") String encryptMobile){
//        return wechatCustomerService.userLoginNoCache(request, buCode, code, source, oneid, encryptMobile);
//    }

    /**
     * 保存、更新客户信息
     *
     * @param
     * @return
     */
    @RequestMapping("/userInfoSaveOrUpdate")
    public ResultVO<?> userInfoSaveOrUpdate(@RequestBody SaveUserInfoRequest request){
        log.info("用户信息保存或更新,请求参数:{}", request);
        return wechatCustomerService.userInfoSaveOrUpdate(request);
    }
}
